package com.aqie.meet;

import android.util.Log;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;

import com.aqie.meet.helper.AppStartHelper;

public class ProcessLifecycleObserver implements LifecycleObserver {
    /**
     * 当app变成前台进程时监听
     * 此方法一次app进入退出只会调用一次
     */
    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    public void enterAppListener(){
        Log.e("ProcessLifecycle","ON_CREATE");
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_START)
    public void  startAppListener(){
        Log.e("ProcessLifecycle","ON_START");
        AppStartHelper.statistics("1");
    }
    @OnLifecycleEvent(Lifecycle.Event.ON_RESUME)
    public void  resumeAppListener(){
        Log.e("ProcessLifecycle","ON_RESUME");
    }
    @OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
    public void  pauseAppListener(){
        Log.e("ProcessLifecycle","ON_PAUSE");
    }
    /**
     * 当app变成后台进程或者退出调用
     * 此方法一次app进入退出只会调用一次
     */
    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    public void  exitAppListener(){
        Log.e("ProcessLifecycle","ON_STOP");
        AppStartHelper.statistics("2");
    }

}
